import { BaseContext } from 'koa';

export default (service: any) => ({
    async addMenu(ctx: BaseContext, next: any) {
        const params = ctx.request.body;
        await service.menu.addMenu(params).then((data: any) => {
            ctx.rest({ id: data._id });
        }).catch((err: any) => {
            ctx.body = { code: 1, message: err.message };
            next();
        });
    }
});